package common;

import entities.TBank;
import interfaces.IBankService ;
import utils.NumberUtil;

public class Bank {

	public static Double markup(Double amount, TBank bank) {
		Double markup = new Double(0);

		if (amount <= bank.getBnkR0()) {
			markup = NumberUtil.div(bank.getBnkP0(), new Double(100), 4);
		} else if (amount <= bank.getBnkR1()) {
			markup = NumberUtil.div(bank.getBnkP1(), new Double(100), 4);
		} else if (amount <= bank.getBnkR2()) {
			markup = NumberUtil.div(bank.getBnkP2(), new Double(100), 4);
		} else if (amount <= bank.getBnkR3()) { 
			markup = NumberUtil.div(bank.getBnkP3(), new Double(100), 4);
		} else if (amount <= bank.getBnkR4()) {
			markup = NumberUtil.div(bank.getBnkP4(), new Double(100), 4);
		} else if (amount <= bank.getBnkR5()) {
			markup = NumberUtil.div(bank.getBnkP5(), new Double(100), 4);
		} else {
			markup = new Double(0);
		}
		return markup;
	}
	
	public static void main(String[] args) throws Exception{
		IBankService bankService = (IBankService) Service.create(IBankService.class);
		
		TBank bank=bankService.fetch ( "CBYEDC1021" );
		System.out.println ( bank ) ;
		
		System.out.println ( NumberUtil.add(new Double(1), markup(new Double(802.22),bank),4) ) ;
	}
}
